package route

import (
	"context"
	"gf_blog_admin/internal/controller/account"
	"gf_blog_admin/internal/controller/content"
	"gf_blog_admin/internal/controller/maintain"
	"gf_blog_admin/internal/controller/system"
	"gf_blog_admin/internal/service"
	"github.com/gogf/gf/v2/net/ghttp"
)

func Register(ctx context.Context, s *ghttp.Server) {
	s.Use(
		service.Middleware().Ctx,
		service.Middleware().CORS,
		service.Middleware().Limiter(20, 10),
		service.Middleware().ResponseHandler,
	)
	s.Group("/", func(group *ghttp.RouterGroup) {
		// 注册后台路由
		group.Group("/api", func(group *ghttp.RouterGroup) {
			group.Middleware(
				service.Middleware().JwtAuth,
				service.Middleware().Permission,
			)
			// 注册控制器
			group.Bind(
				account.NewV1(),
				system.NewV1(),
				maintain.NewV1(),
				content.NewV1(),
			)
		})
	})
}
